<template>
  <div>
    <el-form :model="formData" :rules="rules" ref="form">
      <el-form-item label="年龄" prop="age">
        <el-input v-model.number="formData.age"></el-input>
      </el-form-item>
    </el-form>
    <div class="btn">
      <slot name="btn">
        <el-button type="primary" @click="handlePre">上一步</el-button>
        <el-button type="primary" @click="handleSubmit">提 交</el-button>
      </slot>
    </div>
  </div>
</template>

<script>
import MixinSubForm from "@/components/throwControl/mixinSubForm";

export default {
  name: "formC",
  mixins: [MixinSubForm],
  data() {
    return {
      formData: {
        age: ''
      },
      rules: {
        age: [
          {required: true, message: '年龄必填', trigger: 'change'},
          {type: 'number', message: '年龄必须是数字'},
          {
            validator: (r, v, cb) => {
              if (v <= 0) cb(new Error('年龄必须是正整数'))
              else cb()
            },
            trigger: 'change'
          }
        ]
      }
    }
  }
}
</script>

<style scoped>
.btn {
  margin-top: 20px;
}
</style>
